package com.ex.mzwqz.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.ex.mzwqz.R;
import com.ex.mzwqz.model.CheckEntity;

/**
 * Created by xiaguoqiang on 16/10/23.
 */
public class CheckAdapter extends ArrayAdapter<CheckEntity>{
    private int resource;
    private Context mContext;

    public CheckAdapter(Context context, int resource) {
        super(context, resource);
        this.resource = resource;
        this.mContext = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder vh = null;
        if (vh==null){
            convertView =   LayoutInflater.from(mContext).inflate(resource,null);
            vh = new ViewHolder();
            vh.tvName = (TextView) convertView.findViewById(R.id.tv_user_name);
            vh.tvLocation = (TextView) convertView.findViewById(R.id.tv_loaction);
            vh.tvStatus = (TextView) convertView.findViewById(R.id.tv_status);
            convertView.setTag(vh);
        }else{
            vh = (ViewHolder) convertView.getTag();
        }
        CheckEntity checkEntity = getItem(position);
        vh.tvName.setText(checkEntity.getTitle());
        return convertView;
    }

    class ViewHolder {
        TextView tvName;
        TextView tvLocation;
        TextView tvStatus;
    }
}
